package com.zlq.cn.api;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class TianApiResult<T> {
    private static final int SUCCESS = 200;
    @ApiModelProperty("响应码；200正常")
    private int code;

    @ApiModelProperty("响应提示")
    private String msg;

    @ApiModelProperty("响应数据")
    private T result;

    public T checkCode() {
        if (SUCCESS != code) {
            ResponseException.resultApiError(msg);
        }
        return result;
    }

    public Boolean isOk() {
        return SUCCESS == code;
    }
}
